<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="viewport" id="viewport"
	content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no" />
<link href="./css/reset.css" rel="stylesheet" type="text/css">
<link href="./css/indent-details.css" rel="stylesheet" type="text/css">
<script src="/carworld_weixin/js/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="/carworld_weixin/js/operationNumber.js"></script>
</head>
<body>
	<div class="near-box">
		<a href="javascript:history.back(-1);" class="jd-qrdd-topbox">订单详情</a>
		<div class="jd-qrdd-bigbox">
			<!--地址部分，动态补充-->
			<div class="jd-qrdd-a1">
				<span class="qrdd-a1-img2"></span>
			</div>
			<!--商品部分-->
			<div class="zjzz-buylist-goods1">
				<div class="zjzz-buylist-gtime">
					<span class="zjzz-buylist-gtime1">
						<i class="indent-details-img2"></i>
						茉德精品火锅
					</span>
					<span class="zjzz-buylist-gtime2">联系客服</span>
				</div>
				

			</div>
			<!--商品金额部分-->
			<div class="indent-details-box2">
				<span class="indent-details-text4">总价</span>
				<span class="indent-details-text5" id="total-price">￥0.00</span>
			</div>
			<div class="indent-details-box2">
				<span class="indent-details-text4 tcolor-grey" >优惠金额</span>
				<span class="indent-details-text5 tcolor-black" id="goods-price">￥0.00</span>
			</div>
			<div class="indent-details-box2">
				<span class="indent-details-text4 tcolor-grey">运费</span>
				<span class="indent-details-text5 tcolor-black">￥1.50</span>
			</div>
			<div class="indent-details-box2">
				<span class="indent-details-text4 tcolor-grey">打包费</span>
				<span class="indent-details-text5 tcolor-black">￥1.00</span>
			</div>
			<div class="indent-details-box2">
				<span class="indent-details-text4 tcolor-grey">发票信息</span>
				<span class="indent-details-text5 tcolor-black">不需要发票</span>
			</div>
			
			<div class="indent-details-box2">
				<span class="indent-details-text4 tcolor-grey">配送时间</span>
				<span class="indent-details-text5 tcolor-black">
				16:30&nbsp&nbsp<input type="radio"  id="t1" style="display: inline-block;vertical-align: middle;" name="delivery_time" value="16:30"/>
				20:30&nbsp&nbsp<input type="radio"  id="t2" style="display: inline-block;vertical-align: middle;" name="delivery_time" value="20:30"/>
				</span>
			</div>
			
			<div class="indent-details-box2">
				<span class="indent-details-text4 tcolor-grey">下单备注： </span>
			</div>
			<div style="text-align: center;">
				<textarea class="textarea" id="remarks"></textarea>
			</div>
			<input type="button" class="order-button" value="提交订单" style="color:white;font-size:18px" id="validateBtn"/>
		</div>
	</div>
</body>

<script>
$(function() {
	$.ajax({
		type : 'GET',
		url : '/carworld_weixin/order/takeoutOrderInfo',
		dataType : 'json',
		contentType : 'application/json',
		success : function(data) {
			console.log(data);
			$('.jd-qrdd-a1').empty();
			var orderAdressInfo = null;
			if('null'==data.user.userPosition){
				orderAdressInfo =
				'<span style="margin-left: 3%;">请先添加收货信息</span><a style="float: right; margin-right: 3%" href="/carworld_weixin/ssx/receiving-adress.html">编辑</a>';
			}else{
				orderAdressInfo =
				'<span class="qrdd-a1-t1" id="name">'+data.user.name+'</span><span class="qrdd-a1-t1" id="mobile">'+data.user.mobile+'</span><span class="qrdd-a1-t2">默认</span>'+
				'<a style="float: right; margin-right: 3%" href="/carworld_weixin/ssx/receiving-adress.html">编辑</a><div class="qrdd-a1-b1"><span class="qrdd-a1-img1"></span>'+
				'<span class="qrdd-a1-t3">'+data.user.userPosition+'</span></div>';
			}
			$('.jd-qrdd-a1').append(orderAdressInfo);
			var totalPrice = data.order.shop_order_totalprice;
			var originalPrice = data.order.shop_order_carnumber;
			var nonTakeoutFee = operationNumber(totalPrice,2.5,'-');
			$('#total-price').text('￥'+totalPrice);
			$('#goods-price').text('￥'+ operationNumber(originalPrice,nonTakeoutFee,'-'));
			
			//补充订单信息
			$('#validateBtn').click(function() {
				if('null'==data.user.userPosition){
					alert('请添加您的收货信息~');
					return ;
				}
	
				if($('.qrdd-a1-t3').text() == ''){
					alert('请确保您的收货地址无误~');
					return ;
				}
				
				if($('#name').text() == ''){
					alert('收获联系人姓名不能为空~');
					return ;
				}
				
				if($('#mobile').text() == ''){
					alert('收获联系手机不能为空~');
					return ;
				}
				
				var adress = $('.qrdd-a1-t3').text();
				var district='';
				if(adress.indexOf("海洋大学") != -1){
					district="上海海洋大学";
				}else if(adress.indexOf("海事") != -1){
					district="上海海事大学";
				}else if(adress.indexOf("电机") != -1){
					district="上海电机学院";
				}else if(adress.indexOf("建桥") != -1){
					district="上海建桥学院";
				}else if(adress.indexOf("电力") != -1){
					district="上海电力大学";
				}else{
					district="社区";
				}
				
			/* 	$.ajax({
					type : 'POST',
					url : '/carworld_weixin/order/supplyOrderInfo',
					data : {
						'name' : $('#name').text(),
					    'mobile' : $('#mobile').text(),
						'adress' : $('.qrdd-a1-t3').text(),
						'district': district,
						'remarks' : $("#remarks").val()
					},
					dataType : 'text',
					success : function(result) {
						if(result=='success'){
							var url = "http://food.3kkk.xyz/carworld_weixin/pages/page_userOrder/myOrder.html";
							window.location.href = url + '?timestamp=' + ((new Date()).getTime() + Math.random());
						}else{
							window.location.href='/carworld_weixin/';
						}
					},
					error : function(jqXHR, textStatus, errorThrown) {
						alert(textStatus);
						
					}
				}); */
				
			})
		
		}
	});

});
	
	
</script>
</html>